﻿using System.IO;
using System.Xml.Serialization;

namespace Chess.Common.Network
{
    public sealed class SerializedNetworkWriter : INetworkWriter
    {
        private XmlSerializer _serializer { get; set; }
        private StreamWriter _writer { get; set; }

        public SerializedNetworkWriter(StreamWriter writer)
        {
            _serializer = NetworkUtilities.BuildSerializer();
            _writer = writer;
        }

        public void Write(NetworkData data)
        {
            _serializer.Serialize(_writer, new NetworkPacket(data));
        }
    }
}
